game_manager
{
	spawn
	{
		create
		{
		classname "misc_teleporter_dest"
		origin "-3000 -2400 256"
		targetname "misc_teleporter_dest1"
		angle "-80"
		}

		create
		{
		classname "trigger_teleport"
		target "misc_teleporter_dest1"
		targetname "teleportaal"
        origin "-2305 -1850 -790"
		mins "-50 -50 -60"
		maxs "50 50 15"
		}
		
		create
		{
		life "0"
		dmg "10"
		spawnflags "12"
		origin "-2305 -1850 -830"
		mins "-80 -80 -20"
		maxs "80 80 10"
		classname "trigger_hurt"
		model "*1"
		}
		
		wait 150

		//===================================
		//========= SPAWN MANAGER ===========
		setautospawn "Village" 0
		setautospawn "Hill" 1

		setstate village2 invisible

		setstate cpspawn invisible	
		setstate cpspawn_wo invisible


		// Game rules
		wm_axis_respawntime	25
		wm_allied_respawntime	20
		wm_number_of_objectives 5
		wm_set_round_timelimit	12


		// Objectives

		// Primary:
		// 1: Tank
		// 2: Escorting to Bunker
		// 3: Secret Documents
		// Secondary:
		// 4: Tank Barrier
		// 5: Command Post

		wm_objective_status 1 0 0 // <objective team status>
		wm_objective_status 1 1 0 // status: 0 = default
		wm_objective_status 2 0 0 //		 1 = succeeded
		wm_objective_status 2 1 0 //		 2 = failed
		wm_objective_status 3 0 0
		wm_objective_status 3 1 0
		wm_objective_status 4 0 0
		wm_objective_status 4 1 0
		wm_objective_status 5 0 0
		wm_objective_status 5 1 0

		wm_set_main_objective		1	0
		wm_set_main_objective		1	1
		
		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// If the round timer expires, the Axis have won, so set the current winning team
		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 0

		wait 200
		setstate neutral_cp_toi invisible
		construct defense1
		alertentity shoot_door3
		alertentity shoot_mass
		setstate circuit1_radarbase invisible
		alertentity circuit1_clip
		setstate circuit1_radartop invisible
		trigger shoot_door1 fall
		trigger shoot_door2 fall
			wait 50
		trigger circuit1_radartop down
		trigger self down
	}

	trigger allies_steal_tank
	{
		wm_announce "^1Allied team has stolen the Tank!"

		wm_objective_status 1 0 2
		wm_objective_status 1 1 1


		alertentity village
		setstate village invisible

		setstate village2 default
		alertentity village2

		alertentity village_wo

		
		setautospawn "Village" 1
		setautospawn "Bunker" 0

		wm_set_main_objective 2 0
		wm_set_main_objective 2 1

		trigger game_manager allies_steal_tank_allied_msg
		trigger game_manager allies_steal_tank_axis_msg

	}

	trigger allies_steal_tank_allied_msg
	{
		// *----------------------------------- vo ------------------------------------------*

		wm_teamvoiceannounce 1 "goldrush_allies_tank_stolen"
		wm_teamvoiceannounce 1 "goldrush_allies_tankbars_destroy"

		wm_removeteamvoiceannounce 1 "goldrush_allies_tank_steal"
		// *---------------------------------------------------------------------------------*
	}

	trigger allies_steal_tank_axis_msg
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_tankbars_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_tank_stolen"
		wm_teamvoiceannounce 0 "goldrush_axis_tankbars_construct"

		wm_removeteamvoiceannounce 0 "goldrush_axis_tank_steal"
		// *---------------------------------------------------------------------------------*
	}
}

//=================================================
//=========== COMMAND POST ========================
//=================================================

// ================================================
neutral_cp_toi
{
	trigger show_neutral_cabinet			// Show Neutral Closed CP
	{
		setstate neutral_cp_closed default
		setstate neutral_cp_closed_model default
	}

	trigger hide_neutral_cabinet			// Hide Neutral Closed CP
	{
		setstate neutral_cp_closed invisible
		setstate neutral_cp_closed_model invisible
	}
}

// ================================================
allied_cp_open
{
	spawn
	{
		wait 100
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times

		wait 1000
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*
	}

	trigger disable_cp_features
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1

		sethqstatus 1 0			// Landmines team warning message
		disablespeaker speaker_allied_cp		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		setstate allied_cp_open_model default	// Show open CP model

		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75

		sethqstatus 1 1			// Landmines team warning message
		enablespeaker speaker_allied_cp		// Enable morse code sound
	}

	buildstart final
	{
		trigger neutral_cp_toi hide_neutral_cabinet	// Hide Neutral CP model+clip brush
	}

	built final
	{
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "^3Allied Command Post constructed. Charge speed increased!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"
		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 5 0 2
		wm_objective_status 5 1 1

		setstate cpspawn default
		setstate cpspawn_wo default
		alertentity cpspawn
	}

	decayed final
	{
		setstate allied_cp_open_model invisible	// Hide Open CP model
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
	}

	death
	{
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "^3Axis team has destroyed the Allied Command Post!"
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 5 0 0
		wm_objective_status 5 1 0
	}
}

// ================================================
axis_cp_open
{
	spawn
	{
		wait 100
		constructible_class 2			// Dyno+Satchel

		trigger self disable_cp_features		// Default charge bar times
	}

	trigger disable_cp_features
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model

		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1

		sethqstatus 0 0			// Landmines team warning message
		disablespeaker speaker_axis_cp		// Disable morse code sound
	}

	trigger enable_cp_features
	{
		setstate axis_cp_open_model default	// Show open CP model

		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75

		sethqstatus 0 1			// Landmines team warning message
		enablespeaker speaker_axis_cp		// Enable morse code sound
	}

	buildstart final
	{
		trigger neutral_cp_toi hide_neutral_cabinet	// Hide Neutral CP model+clip brush
	}

	built final
	{
		trigger self enable_cp_features		// Increase charge bar times

		wm_announce "^3Axis Command Post constructed. Charge speed increased!"
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"
		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 5 0 1
		wm_objective_status 5 1 2
	}

	decayed final
	{
		setstate axis_cp_open_model invisible	// Hide Open CP model
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
	}

	death
	{
		trigger neutral_cp_toi show_neutral_cabinet	// Show Neutral CP model+clip brush
		trigger self disable_cp_features		// Default charge bar times

		wm_announce "Allied team has destroyed the Axis Command Post!"
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *----------------------------------- vo ------------------------------------------*

		wm_objective_status 5 0 0
		wm_objective_status 5 1 0
	}
}

//=====================================================================
//======================== TANK =======================================
//=====================================================================

//=============================================================================
//=== Tank Mapscript
//=============================================================================
//	accum 0, script lock
//	accum 1, current movement path position
//	accum 2, track state
//	accum 3, bit 0	death status		(0=dead, 1=alive)
//		 bit 1	stuck status		(0=not stuck, 1=stuck)
//		 bit 2	players nearby		(0=no players, 1=players)
//		 bit 3	moving status		(0=not moving, 1=moving)
//		 bit 4	temp register
//		 bit 5	message-flag		(0=no message, 1=message)
//		 bit 6	visible state		(0=alive, 1=dead)
//		 bit 7	barricade #1		(0=not built, 1=built)
//		 bit 8	barricade #2		(0=not built, 1=built)
//		 bit 9	barricade #3		(0=not built, 1=built)
//		 bit 10	barricade #4		(0=not built, 1=built)
//	accum 4, stop counter
//

//info_notnull
tank_sound
{
	trigger start
	{
		trigger tank sound_start
		wait 3400
		trigger tank sound_move
	}
	trigger stop
	{
		trigger tank sound_stop
		wait 1400
		trigger tank sound_idle
	}
	trigger death
	{
		trigger tank sound_death
		wait 3400
		trigger tank sound_idle
	}
	trigger rebirth
	{
		trigger tank sound_rebirth
		wait 3400
		trigger tank sound_idle
	}
}

//script_mover
tank
{
	// ===========================================================================================
	spawn
	{
		wait 50

		constructible_chargebarreq 1.0
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10

		followspline 0 path_00 10000 wait length -64

		trigger self sound_idle
		trigger self tracks_stop
		trigger self barricade1_destroyed
	}


	// ===========================================================================================
	// script lockouts
	trigger script_lock
	{
		accum 0 inc 1
	}

	trigger script_unlock
	{
		accum 0 inc -1
	}


	// ===========================================================================================
	// tracks
	trigger tracks_forward
	{
		accum 2 abort_if_equal 1
		accum 2 set 1
		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshaderflush
	}

	trigger tracks_stop
	{
		accum 2 abort_if_equal 0
		accum 2 set 0
		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_left
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_right
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_left
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_right
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_left
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_right
		remapshaderflush
	}

	trigger tracks_turn_left
	{
		accum 2 abort_if_equal 2
		accum 2 set 2
		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshaderflush
	}

	trigger tracks_turn_right
	{
		accum 2 abort_if_equal 3
		accum 2 set 3
		remapshader models/mapobjects/tanks_sd/jag_tracks_left 	models/mapobjects/tanks_sd/jag_tracks_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_tracks_right models/mapobjects/tanks_sd/jag_tracks_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_wheels_left 	models/mapobjects/tanks_sd/jag_wheels_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_wheels_right models/mapobjects/tanks_sd/jag_wheels_alt_backward
		remapshader models/mapobjects/tanks_sd/jag_cogs_left 	models/mapobjects/tanks_sd/jag_cogs_alt_forward
		remapshader models/mapobjects/tanks_sd/jag_cogs_right 	models/mapobjects/tanks_sd/jag_cogs_alt_backward
		remapshaderflush
	}


	// ========================================
	// sound stuff
	trigger sound_idle
	{
		stopsound
		playsound sound/vehicles/tank/tank_idle.wav looping volume 512
	}
	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/tank/tank_revup.wav volume 196
	}
	trigger sound_move
	{
		stopsound
		playsound sound/vehicles/tank/tank_move.wav looping volume 512
	}
	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/tank/tank_revdown.wav volume 196
	}
	trigger sound_death
	{
		stopsound
		playsound sound/vehicles/tank/tank_stop.wav volume 256
	}
	trigger sound_rebirth
	{
		stopsound
		playsound sound/vehicles/tank/tank_start.wav volume 196
	}


	// ===========================================================================================
	// enable/disable
	trigger tank_enable
	{
		trigger self stuck_check
		accum 3 abort_if_bitset 1 		// stuck check
		accum 4 set 0				// reset stop counter
		accum 3 bitreset 2			// reset player check
		accum 3 abort_if_bitset 3 		// already following spline
		accum 0 abort_if_not_equal 0		// are we not in a script lockout?
		accum 3 abort_if_bitset 0 		// death check

		trigger self script_lock
		trigger tank_sound start
		startanimation 55 10 15 nolerp norandom
		wait 666
		startanimation 5 40 15 nolerp norandom
		wait 500
		trigger self tracks_forward
		trigger self script_unlock

		trigger self move
	}

	trigger tank_disable
	{
		accum 4 inc 1				// up the stop counter
		accum 4 abort_if_less_than 2		// 2 second ride
		accum 3 bitset 2			// set player check
		trigger self deathcheck
	}


	// ===========================================================================================
	// stuck checking
	trigger stuck_check
	{
		accum 3 bitreset 1			// accum 3, bit 1	stuck status	(0=not stuck, 1=stuck)
		trigger self stuck_check_scriptlockout
		trigger self stuck_check_finished
		trigger self stuck_check_barrier1_built
	}

	trigger stuck_check_barrier1_built
	{
		accum 1 abort_if_not_equal 14
		accum 3 abort_if_not_bitset 7
		accum 3 bitset 1	// stuck
	}

	trigger stuck_check_finished
	{
		accum 1 abort_if_less_than 17
		accum 3 bitset 1
	}


	trigger stuck_check_scriptlockout
	{
		accum 0 abort_if_equal 0
		accum 3 bitset 1
	}

	// ===========================================================================================
	// stop check
	trigger stopcheck_setup
	{
		accum 3 bitset 4			// stop if we're stuck/no-one's pushing :)
		accum 3 abort_if_bitset 2		// no one in the trigger, abort
		trigger self stuck_check		// call the stop check function
		accum 3 abort_if_bitset 1		// we're stuck so break out
		accum 3 bitreset 4			// we're free to move
	}

	trigger stopcheck
	{
		trigger self stopcheck_setup
		accum 3 abort_if_not_bitset 4

		trigger self script_lock
		// Any just stopped moving stuff goes here
		trigger tank_sound stop
		trigger self tracks_stop
		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom
		wait 900
		trigger self script_unlock

		resetscript
	}


	// ===========================================================================================
	// death / rebirth
	trigger deathcheck
	{
		accum 3 abort_if_not_bitset 0		// are we dead?
		accum 3 abort_if_bitset 6		// are we not already visibly dead?
		accum 3 abort_if_bitset 3		// are we not following a spline?
		accum 0 abort_if_not_equal 0		// are we not in a script lockout?
		accum 3 bitset 6			// we're now visibly dead
		accum 3 bitset 5

		changemodel models/mapobjects/tanks_sd/jagdpanther_africa_tracks2.md3
		setstate tank_smoke default
		kill tank_construct
		trigger self sound_death
		trigger self tracks_stop

		trigger self script_lock
		trigger self tracks_stop
		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom
		trigger self script_unlock

		resetscript
	}

	rebirth
	{
		accum 3 bitreset 6 			// we're visibly alive
		accum 3 bitreset 0 			// we're alive again

		trigger self script_lock
		changemodel models/mapobjects/tanks_sd/jagdpanther_africa_tracks.md3
		setstate tank_smoke invisible
		trigger tank_sound rebirth
		wait 500
		trigger self script_unlock
	}

	death
	{
		accum 3 bitset 0
	}


	// ===========================================================================================
	// movement
	trigger run_continue
	{
		accum 1 inc 1
		trigger self deathcheck
		trigger self stopcheck
		trigger self move
	}

	trigger move
	{
		trigger self move_check
		wait 500
		trigger self move
	}

	trigger move_check
	{
		trigger self stuck_check
		accum 3 abort_if_bitset 1
		accum 1 trigger_if_equal 0 tank move_to_0
		accum 1 trigger_if_equal 1 tank move_to_1
		accum 1 trigger_if_equal 2 tank move_to_2
		accum 1 trigger_if_equal 3 tank move_to_3
		accum 1 trigger_if_equal 4 tank move_to_4
		accum 1 trigger_if_equal 5 tank move_to_5
		accum 1 trigger_if_equal 6 tank move_to_6
		accum 1 trigger_if_equal 7 tank move_to_7
		accum 1 trigger_if_equal 8 tank move_to_8
		accum 1 trigger_if_equal 9 tank move_to_9
		accum 1 trigger_if_equal 10 tank move_to_10
		accum 1 trigger_if_equal 11 tank move_to_11
		accum 1 trigger_if_equal 12 tank move_to_12
		accum 1 trigger_if_equal 13 tank move_to_13
		accum 1 trigger_if_equal 14 tank move_to_14
		accum 1 trigger_if_equal 15 tank move_to_15
		accum 1 trigger_if_equal 16 tank move_to_16
		accum 1 trigger_if_equal 17 tank move_to_17
	}

	trigger move_to_0
	{
		accum 1 set 1
		trigger self move_to_1
		//trigger self run_continue
	}

	trigger move_to_1
	{
		trigger self tracks_forward
		
		trigger game_manager allies_steal_tank

		accum 3 bitset 3
		followspline 0 path_0 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_2
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_1 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_3
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_2 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_4
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_3 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_5
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_4 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_6
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_5 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_7
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_6 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_8
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_7 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_9
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_8 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_10
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_9 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_11
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_10 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_12
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_11 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_13
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_12 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_14
	{
		trigger self tracks_forward
		accum 3 bitset 3

		trigger defense1 remove

		followspline 0 path_13 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_15
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_14 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger move_to_16
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_15 75 wait length -64
		accum 3 bitreset 3
		trigger tank_turret turn

		setstate tank_trigger invisible
		setstate tank_enabler invisible
		setstate tank_build invisible

		trigger self run_continue
	}

	trigger move_to_17
	{
		trigger self tracks_forward
		accum 3 bitset 3
		followspline 0 path_16 75 wait length -64
		accum 3 bitreset 3
		trigger self run_continue
	}

	trigger barricade1_constructed
	{
		accum 3 bitset 7
	}
	trigger barricade1_destroyed
	{
		accum 3 bitreset 7
	}

	//-----------------------------------
	// Turret
	//-----------------------------------
	trigger startfire
	{
		startanimation 67 8 10 nolerp norandom noloop
	}

	trigger stopfire
	{
		startanimation 0 1 15 nolerp norandom
	}
}

tank_shell
{
	spawn
	{
		wait 400
		attachtotag tank tag_tank
	}
}

//target_script_trigger
tank_disabler
{
	trigger run
	{
		trigger tank tank_disable
	}
}

//target_script_trigger
tank_enabler
{
	trigger run
	{
		trigger tank tank_enable
	}
}

//trigger_multiple
tank_trigger
{
	spawn
	{
		wait 100
		attachtotag tank_shell tag_turret
	}
}

//trigger_objective_info
tank_build
{
	spawn
	{
		wait 100
		attachtotag tank_shell tag_turret
	}
}

//func_constructible
tank_construct
{
	spawn
	{
		wait 400

		kill tank

		constructible_class 2
		constructible_health 1200
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
	}

	built final
	{
		alertentity tank
		wm_announce "The tank has been repaired"
	}

	trigger final_pos
	{
		constructible_constructxpbonus 2
		constructible_destructxpbonus 5
	}
}

//misc_gamemodel
tank_turret
{
	spawn
	{
		wait 500
		attachtotag tank_shell tag_turret
	}
	trigger turn
	{
		wait 1000

		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 8 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav

		wait 500

		trigger tank startfire
		playsound sound/vehicles/tank/tank_fire.wav
		trigger tank_flash run	
	}


	trigger blow
	{
		setstate tank_flash invisible

		alertentity shoot_door3
		alertentity shoot_mass
		setstate circuit1_radarbase invisible
		alertentity circuit1_clip
		setstate circuit1_radartop invisible
		trigger obj sound
		
		wait 200
		trigger tank stopfire

		setstate tank_flash invisible

		wm_announce "^1Allied team has opened the Bunker!"
		
		wm_objective_status 2 0 2
		wm_objective_status 2 1 1
		
		wm_set_main_objective		3	0
		wm_set_main_objective		3	1
		
		//---------------VOICE--------------------
				
		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"
		wm_teamvoiceannounce 0 "axis_hq_objective_destroyed"

		//----------------------------------------

		
		wait 400

		trigger shoot_door1 fall
		trigger shoot_door2 fall

		wait 500

		playsound sound/vehicles/tank/turret_spin.wav looping
		faceangles 0 0 0 3000
		stopsound
		playsound sound/vehicles/tank/turret_end.wav

	}

}

tank_smoke
{
	spawn
	{
		wait 300
		attachtotag tank_shell tag_smoke
		setstate tank_smoke invisible
	}
}

tank_flash
{
	spawn
	{
		setstate tank_flash invisible
	}
	trigger run
	{
		setstate tank_flash default
 		attachtotag tank_turret tag_flash
		faceangles 0 90 0 50
		resetscript

		wait 50

		trigger tank_turret blow
	}
}
//=============================================================================
//=== Barricade 1 Mapscript
//=============================================================================
defense1
{
	spawn
	{
		wait 400
		setstate defense1_materials invisible
		setstate defense1_materials_clip invisible
		setstate defense1_flag invisible
		constructible_class 3
		constructible_chargebarreq 1.5
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
		trigger tank barricade1_constructed
	}
	buildstart final
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default
	}
	built final
	{
		setstate defense1_materials invisible
		setstate defense1_materials_clip invisible
		setstate defense1_flag invisible
		//inform the tank that this barricade has been built
		trigger tank barricade1_constructed

		wm_objective_status 4 0 1
		wm_objective_status 4 1 2
	}
	decayed final
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default
	}
	death
	{
		setstate defense1_materials default
		setstate defense1_materials_clip default
		setstate defense1_flag default
		trigger tank barricade1_destroyed
		wm_announce "Tank Barrier has been destroyed."

		wm_objective_status 4 0 2
		wm_objective_status 4 1 1
	}
	trigger remove
	{
		setstate defense1_toi invisible
		setstate defense1_materials invisible
		setstate defense1_materials_clip invisible
		setstate defense1_flag invisible

		wm_announce "^3The Tank has passed Tank Barrier #1"

		wm_teamvoiceannounce 1 "goldrush_allies_tank_barrier1"
		wm_teamvoiceannounce 0 "goldrush_axis_tank_barrier1"

		wm_objective_status 4 0 2
		wm_objective_status 4 1 1

		remove
	}
}


//==========================================================
//================ Secret Documents ========================
//==========================================================

obj
{
	spawn
	{
	remove
	}

	trigger sound
	{
		playsound sound/weapons/dynamite/dynamite_expl.wav
	}
	
	trigger stolen
	{
	
		setstate obj_toi invisible
		setstate t24 invisible
	
	}
	
	trigger returned
	{
	
		setstate obj_toi default
		setstate t24 default
	
	}
	
	trigger captured
	{
		wm_announce "^1Allies successfully secured the Secret Documents!"
		
		wm_objective_status 3 0 2
		wm_objective_status 3 1 1
		
		wm_setwinner 1
		wm_endround
	}
}

circuit1_radartop
{
	spawn
	{
	remove
		accum 1 set 0	// 0:Down 1:Up
		accum 2 set 0	// 0:Stationary 1:Moving
		accum 3 set 0	// requested direction
		wait 50
		trigger circuit1_radartop up
	}

	trigger up
	{
		accum 3 set 1

		accum 1 abort_if_equal 1		// Abort if UP already
		accum 2 abort_if_equal 1		// Abort if moving already

		stopsound
		playsound sound/vehicles/misc/radar_start.wav volume 64	// radar start sound

		accum 2 set 1				// Moving, DND
		startanimation 0 35 15 nolerp norandom noloop
		wait 2500
		startanimation 34 1 15 norandom noloop	// Client PVS issue
		setrotation 0 30 0
		accum 2 set 0				// Finished
		accum 1 set 1				// Now in UP status

		enablespeaker radar1_sound	// radar spinning sound

		accum 3 abort_if_equal 1

		trigger self down
	}

	trigger down
	{
		accum 3 set 0

		accum 1 abort_if_equal 0		// Abort if DOWN already
		accum 2 abort_if_equal 1		// Abort if moving already

		disablespeaker radar1_sound		// radar spinning sound
		playsound sound/vehicles/misc/radar_end.wav volume 64	// radar stop sound

		accum 2 set 1				// Moving, DND
		stoprotation
		startanimation 34 29 15 nolerp norandom noloop
		wait 2500
		startanimation 0 1 15 norandom noloop	// Client PVS issue
		accum 2 set 0				// Finished
		accum 1 set 0				// Now in DOWN status

		accum 3 abort_if_equal 0

		trigger self up
	}
}

shoot_door1
{
	spawn
	{
	}

	trigger fall
	{
		playsound sound/movers/doors/door5_locked.wav
		wait 150
		playsound sound/movers/doors/door5_open.wav
		faceangles 85 0 0 1000
		alertentity door1_clip
		playsound sound/movers/doors/door5_locked.wav
	}
}

shoot_door2
{
	spawn
	{
	}

	trigger fall
	{
		playsound sound/movers/doors/door5_locked.wav
		wait 250
		playsound sound/movers/doors/door5_open.wav
		faceangles 0 0 85 1000
		alertentity door2_clip
		playsound sound/movers/doors/door5_locked.wav
	}
}




